package net.javlov.util;

import java.io.IOException;

import org.jdom.Document;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;

public class SAXReader {
	
	public static Document read(String XMLFile) {
		SAXBuilder builder = new SAXBuilder();
		
		Document doc = null;
		try {
			doc = builder.build(XMLFile);
		} catch (IOException e) {
			System.err.println("Error opening file " + XMLFile + ": " + e.getMessage());
			return null;
		} catch (JDOMException e) {
			System.err.println("Error parsing file " + XMLFile + ": " + e.getMessage());
			return null;
		}
		
		return doc;
	}
}
